package com.eveinfo.api.transaction;

import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import com.eveinfo.api.AbstractApiParser;
import com.eveinfo.api.ApiAuth;
import com.eveinfo.api.ApiException;
import com.eveinfo.api.NoCacheFoundExecption;

public class TransactionParser extends
		AbstractApiParser<ApiWallet, WalletTransactionHandler> {
	protected static final String TRANSACTIONS_URL = "/WalletTransactions.xml.aspx";

	private static TransactionParser instance;
	
	public static TransactionParser getInstance(){
		if(instance == null){
			instance = new TransactionParser();
		}
		return instance;
	}
	
	private TransactionParser() {
		super(ApiWallet.class, 2, TRANSACTIONS_URL);
	}

	public ApiWallet getTransactions(ApiAuth auth, boolean corporation)
			throws IOException, SAXException, ParserConfigurationException,
			ApiException, NoCacheFoundExecption {
		WalletTransactionHandler handler = new WalletTransactionHandler();
		if (corporation)
			return getResponse(auth, Path.CORP, handler);
		return getResponse(auth, Path.CHARACTER, handler);
	}

	public static boolean isInstancier() {
		return instance != null;
	}

}